﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Drawing;
using System.Data;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using Gencode.PrsCommon.Data.Abteilung;
using Gencode.PrsCommon.Data.Plan;

namespace Personalplaner.Gui.Mask
{
    [ToolboxItem(false)]
	public partial class AddLineToPlan : UserControl, Gencode.Gengui.Forms.IDialogControl
	{
		DataView m_abteilungen;
		int planid;

		public AddLineToPlan(int planid)
		{
			InitializeComponent();

			this.planid = planid;

			m_abteilungen = AbteilungData.GetAbteilungen(Verwaltung.Mandant, false);
			comboAbteilung.DataSource = m_abteilungen;
			comboAbteilung.DisplayMember = "name";
		}

		#region IDialogControl Members

		public bool OKClicked()
		{
			if (comboAbteilung.SelectedIndex >= 0)
			{
				int abtid = int.Parse(m_abteilungen[comboAbteilung.SelectedIndex].Row["AbteilungID"].ToString());
				PlanData.SetAdditionalPersonInPlan(planid, -1, abtid);
			}
			else
				return false;

			return true;
		}

		public bool CancleClicked()
		{
			return true;
		}

		#endregion
	}
}
